<?php
$http = new Swoole\Http\Server("0.0.0.0", 8811);


$http->set([
    'document_root' => '/data/swoole/view/', // v4.4.0以下版本, 此处必须为绝对路径
    'enable_static_handler' => true,
    'worker_num'=>5,
]);

$http->on("WorkerStart",function ($server, $worker_id){
    require __DIR__ . '/../vendor/autoload.php';
});

$http->on('request', function ($request, $response) {
    //var_dump($request->get, $request->post);
    $response->cookie("swoole", "learn", time()+1800);
    $response->header("Content-Type", "text/html; charset=utf-8");
    $response->end("server-get".json_encode($request->get));
});

$http->start();